package com.zero.mxshengadmin.modules.website.controller;

import com.zero.mxshengadmin.common.utils.R;
import com.zero.mxshengadmin.modules.website.entity.WebsiteAdvertiseEntity;
import com.zero.mxshengadmin.modules.website.entity.WebsiteBannerEntity;
import com.zero.mxshengadmin.modules.website.service.WebsiteBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by aicaikeji on 2019/4/3.
 */

@RestController
public class WebsiteBannerController {
    @Autowired
    private WebsiteBannerService websiteBannerService;


    /**
     * 添加轮播
     * @param entity
     * @return
     */
    @PostMapping("/website/banner/add")
    public R save(@RequestBody WebsiteBannerEntity entity) {
        websiteBannerService.save(entity);
        return R.ok();
    }

    /**
     * 删除轮播
     * @param ids
     * @return
     */
    @PostMapping("/website/banner/delete")
    public R delete(@RequestBody Long[] ids) {
        websiteBannerService.removeByIds(ids);
        return R.ok();
    }

    /**
     * 更新轮播
     * @param entity
     * @return
     */
    @PostMapping("/website/banner/update")
    public R update(@RequestBody WebsiteBannerEntity entity) {
        websiteBannerService.update(entity);
        return R.ok();
    }

    /**
     * 查询轮播招聘
     * @param id
     * @return
     */
    @GetMapping("/website/banner/find/{id}")
    public R find(@PathVariable("id") Long id) {
        WebsiteBannerEntity entity = websiteBannerService.getById(id);
        return R.ok().put("result",entity);
    }

    /**
     * 查询轮播列表
     * @return
     */
    @GetMapping("/website/banner/list")
    public R findList() {
        List<WebsiteBannerEntity> list = websiteBannerService.list();
        return R.ok().put("result",list);
    }
}
